package gam.n1.ins.i;

import gam.n1.areas.Area;
import gam.n1.areas.impl.a.DefendVArea;
import gam.n1.ent.i.entitys.AbstractZombie;
import gam.n1.ins.Instance;
import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitTask;

import java.util.concurrent.TimeUnit;

public class TestIns implements Instance {
    private final long aT;
    private long lT;
    private BukkitTask sT;

    public TestIns(long aT) {
        this.aT = aT;
    }

    @Override
    public Boolean apply(Area area) {
        lT = System.currentTimeMillis();
        long $T = lT - area.currentTime();
        if ($T <= aT && area instanceof DefendVArea){
            System.out.println("Area Spawn " + (sT == null));
            if (sT == null){
                sT = Bukkit.getScheduler().runTask(area.plugin(), ()-> {
                    ((DefendVArea) area).spawn();
                    area.refresh();
                    sT = null;
                });
            }
        } else return true;
        return false;
    }
}
